import jsonp from '@/modules/corejs/ajax/jsonp'

export default function getWeatherInfo (city, cb) {
  // jsonp({
  //   url: 'http://wis.qq.com/city/like',
  //   data: {
  //     source: 'pc',
  //     city: cityName
  //   }
  // }).then(d => {
  //   let {data} = d
  //   let city = ''
  //   for (let k in data) {
  //     city = data[k]
  //     break
  //   }
  if (city) {
    let params = {
      source: 'pc',
      weather_type: 'observe|air'
    }
    city = city.split(',')
    city.forEach((v, i) => {
      params[['province', 'city', 'county'][i]] = v.trim()
    })

    jsonp({
      url: 'http://wis.qq.com/weather/common',
      data: params
    }).then(d => {
      if (d.status === 200) {
        cb(d.data)
      }
    })
  }
  // })
}
